<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>

<style type="text/css">
	*{padding: 0;margin: 0;}
	body,html{width: 100%;height:100%;}
	body>div{padding-left:10px;}
	h1{margin-top: 10px;margin-left: 10px;}
	.point_box{margin-top: 10px;margin-left: 10px;line-height: 30px;height: 30px;}
	.point_box>span{line-height: 30px;height: 30px;display: inline-block;float: left;margin-right: 10px;}
	.point_box>div{display: inline-block;margin-left: 30px;}
	.point_box>div>a{float: left;width: 100px;text-align: center;line-height: 30px;height: 30px;}
	.point_box>div>a:first-child{background: blue;border-radius: 50px 0 0 50px;cursor: pointer;color: white;}
	.point_box>div>a+a{background: #ccc;border-radius: 0 50px 50px 0;}
	#avatar{width: 80px;height: 80px;border-radius: 50%;border: 1px solid #ccc;margin-top: 10px;}
</style>
</head>
<body>

<div>
	<a href="###" onclick="changeThumb()"><img id="avatar" alt="" src="{$Think.session.user.thumb}"></a>
	<h1>{$Think.session.user.username}</h1>
	<div class="point_box">
		
		<span>用户积分</span>
		<span class="point" id='point'>{$point}</span>
		<div>
			<if condition='$can_sign == 1'>
			<a style="color: black;background: #ccc;cursor: text;">已签到</a>
			<else/>
			<a onclick="qiandao(this,'{:U('User/qiandao',array('user_id'=>$_SESSION['user']['id']))}')">签到</a>
			</if>
			<a>连续签到{$sign_count}天</a>
		</div>
	</div>
</div>

</body>

<script type="text/javascript" src="/Public/Admin/lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="__PUBLIC_ADMIN__lib/layer/2.4/layer.js"></script>
<script type="text/javascript">
	function qiandao(obj,url){
		$.post(url,{},function(data){
			if(data.status == 1){
				$('#point').text(data.point);
				$(obj).css({background:'#ccc',color:'black',cursor:'text'});
				$(obj).attr('onclick','');
				$(obj).text('已签到');
				$(obj).next().text('连续签到'+data.sign_count+'天');
			}else{
				alert('签到失败，请重试');
			}
		})
	}
	
	function changeThumb(){
		var index = layer.open({
			  type: 1 //此处以iframe举例
			  ,title: '请选择头像'
			  ,area: ['700px', '400px']
			  ,maxmin: true
			  ,content: '{$allThumb}'
			  ,btn: ['确定', '取消'] 
			  ,yes: function(){
				var loadIndex = layer.load();
			    var thumb = $('img[select=select]').attr('src');
			    $.post('{:('changeThumb')}',{thumb:thumb},function(res){
			    	if(res == 1){
			    		layer.close(loadIndex);
			    		layer.close(index);
			    		$('#avatar').attr('src',thumb);
			    	}else{
			    		layer.close(loadIndex);
			    		layer.msg('修改失败，请重试!',{icon:5,time:1000});
			    	}
			    });
			  }
			  ,btn2: function(){
			    layer.close(index);
			  }
			});
	}
	
	function selectThumb(obj){
		$('.selectThumb').each(function (){
			$(this).next().hide();
			$(this).attr('select','');
		});
		$(obj).next().show();
		$(obj).attr('select','select');
	}
</script>


</html>